Skip to content

feat: add BatchSizeTooLarge error to IPolicyRegistry#69

Merged
ilikesymmetry merged 2 commits into
mainfrom
feat/policy-audit
May 23, 2026
Merged

feat: add BatchSizeTooLarge error to IPolicyRegistry#69
ilikesymmetry merged 2 commits into
mainfrom
feat/policy-audit

Conversation

@rayyan224
Copy link
Copy Markdown
Collaborator

Summary

  • Adds BatchSizeTooLarge(uint256 maxBatchSize) to IPolicyRegistry to match the Rust PolicyRegistry precompile batch limit revert
  • Documents that the error applies to createPolicyWithAccounts, updateAllowlist, and updateBlocklist

Related

Test plan

  • Interface compiles with existing PolicyRegistry tests
  • CI green

Made with Cursor

Document the registry membership batch limit revert so the Solidity
interface matches the Rust PolicyRegistry precompile.

Co-authored-by: Cursor <cursoragent@cursor.com>
@ilikesymmetry ilikesymmetry self-requested a review May 22, 2026 23:56
Copy link
Copy Markdown
Collaborator

@ilikesymmetry ilikesymmetry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we have the error in interface, we should also include tests against our mocks so that we can validate intended behavior against real precompiles with fork tests

Per review feedback: with the error declared on the interface, the
mock should mirror the Rust precompile's behavior so the same
interface-level tests pass in fork-test mode against the real
PolicyRegistry. base/base#2876 sets the limit at 64 accounts per call.

- MockPolicyRegistry: add `MAX_BATCH_SIZE = 64` (internal) and a
  pre-mutation length check in `_batchSetMembers` that reverts with
  `BatchSizeTooLarge(MAX_BATCH_SIZE)`. The check sits at the shared
  funnel so all three entry points (`createPolicyWithAccounts`,
  `updateAllowlist`, `updateBlocklist`) inherit it without
  duplication.
- PolicyRegistryTest: expose `MAX_BATCH_SIZE` as a compile-time
  constant on the test base (kept as a literal, not pulled from the
  mock, so fork tests against the real precompile share it) and add
  `_makeAccounts(n)` for batch-bound tests that need to bypass the
  existing 0..5 `_boundAccounts` cap.
- Tests: per affected entrypoint, add one revert test (fuzz over a
  size above the limit) and one inclusive-boundary success test
  (batch size exactly == MAX_BATCH_SIZE).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ilikesymmetry
Copy link
Copy Markdown
Collaborator

Added in cb5cd92. The mock now enforces the 64-account limit at the shared _batchSetMembers funnel and reverts with BatchSizeTooLarge(MAX_BATCH_SIZE). Per-entrypoint coverage added:

  • test_createPolicyWithAccounts_revert_batchSizeTooLarge + _success_batchAtLimit
  • test_updateAllowlist_revert_batchSizeTooLarge + _success_batchAtLimit
  • test_updateBlocklist_revert_batchSizeTooLarge + _success_batchAtLimit

The revert tests fuzz over arbitrary over-the-limit sizes; the success tests pin the inclusive boundary at exactly 64. MAX_BATCH_SIZE is kept as a compile-time literal on PolicyRegistryTest so the same tests are directly portable to fork-test mode against the real Rust precompile.

Heads up: this branch was based on a fairly old main (predates several renames and the PolicyRegistry mocks refactor in #71). The new tests work on the current branch but will likely conflict on rebase — happy to rebase next.

@ilikesymmetry ilikesymmetry merged commit 766c7b1 into main May 23, 2026
3 checks passed
@ilikesymmetry ilikesymmetry deleted the feat/policy-audit branch May 23, 2026 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants